char sprintf_buf[SPRINTF_BUFSIZE];
ptrdiff_t sprintf_bytes;
if (conversion == 'e' || conversion == 'f' || conversion == 'g')
- {
- double x = (INTEGERP (args[n])
- ? XINT (args[n])
- : XFLOAT_DATA (args[n]));
- sprintf_bytes = sprintf (sprintf_buf, convspec, prec, x);
- }
+ sprintf_bytes = sprintf (sprintf_buf, convspec, prec,
+ XFLOATINT (args[n]));
else if (conversion == 'c')
{
/* Don't use sprintf here, as it might mishandle prec. */
extract_float (Lisp_Object num)
{
CHECK_NUMBER_OR_FLOAT (num);
-
- if (FLOATP (num))
- return XFLOAT_DATA (num);
- return (double) XINT (num);
+ return XFLOATINT (num);
}
\f
/* Trig functions. */
doc: /* Return the exponential ARG1 ** ARG2. */)
(Lisp_Object arg1, Lisp_Object arg2)
{
- double f1, f2, f3;
-
CHECK_NUMBER_OR_FLOAT (arg1);
CHECK_NUMBER_OR_FLOAT (arg2);
if (INTEGERP (arg1) /* common lisp spec */
XSETINT (val, acc);
return val;
}
- f1 = FLOATP (arg1) ? XFLOAT_DATA (arg1) : XINT (arg1);
- f2 = FLOATP (arg2) ? XFLOAT_DATA (arg2) : XINT (arg2);
- f3 = pow (f1, f2);
- return make_float (f3);
+ return make_float (pow (XFLOATINT (arg1), XFLOATINT (arg2)));
}
DEFUN ("log", Flog, Slog, 1, 2, 0,
{
case Lisp_Float:
{
- double d1, d2;
-
- d1 = extract_float (o1);
- d2 = extract_float (o2);
+ double d1 = XFLOAT_DATA (o1);
+ double d2 = XFLOAT_DATA (o2);
/* If d is a NaN, then d != d. Two NaNs should be `equal' even
though they are not =. */
return d1 == d2 || (d1 != d1 && d2 != d2);
if (NILP (new_value))
f->gamma = 0;
- else if (NUMBERP (new_value) && extract_float (new_value) > 0)
+ else if (NUMBERP (new_value) && XFLOATINT (new_value) > 0)
/* The value 0.4545 is the normal viewing gamma. */
- f->gamma = 1.0 / (0.4545 * extract_float (new_value));
+ f->gamma = 1.0 / (0.4545 * XFLOATINT (new_value));
else
signal_error ("Invalid screen-gamma", new_value);
INLINE double
NUMVAL (Lisp_Object x)
{
- return NUMBERP (x) ? extract_float (x) : -1;
+ return NUMBERP (x) ? XFLOATINT (x) : -1;
}
INLINE double
for (i = 0;
i < 9 && CONSP (matrix) && NUMBERP (XCAR (matrix));
++i, matrix = XCDR (matrix))
- trans[i] = extract_float (XCAR (matrix));
+ trans[i] = XFLOATINT (XCAR (matrix));
}
else if (VECTORP (matrix) && ASIZE (matrix) >= 9)
{
for (i = 0; i < 9 && NUMBERP (AREF (matrix, i)); ++i)
- trans[i] = extract_float (AREF (matrix, i));
+ trans[i] = XFLOATINT (AREF (matrix, i));
}
if (NILP (color_adjust))
color_adjust = make_number (0xffff / 2);
if (i == 9 && NUMBERP (color_adjust))
- x_detect_edges (f, img, trans, extract_float (color_adjust));
+ x_detect_edges (f, img, trans, XFLOATINT (color_adjust));
}
value = image_spec_value (spec, QCscale, NULL);
if (NUMBERP (value))
- scale = extract_float (value);
+ scale = XFLOATINT (value);
/* If width and/or height is set in the display spec assume we want
to scale to those values. If either h or w is unspecified, the
value = image_spec_value (img->spec, QCrotation, NULL);
if (FLOATP (value))
{
- rotation = extract_float (value);
+ rotation = XFLOAT_DATA (value);
status = MagickRotateImage (image_wand, bg_wand, rotation);
if (status == MagickFalse)
{
CHECK_TYPE (INTEGERP (x), Qinteger_or_marker_p, x); \
} while (false)
+INLINE double
+XFLOATINT (Lisp_Object n)
+{
+ return FLOATP (n) ? XFLOAT_DATA (n) : XINT (n);
+}
+
INLINE void
CHECK_NUMBER_OR_FLOAT (Lisp_Object x)
{
/* Compute timeout. */
if (NUMBERP (seconds))
{
- double duration = extract_float (seconds);
+ double duration = XFLOATINT (seconds);
struct timespec wait_time = dtotimespec (duration);
end_time = timespec_add (current_timespec (), wait_time);
}
int old_dy = w->vscroll;
w->vscroll = - (NILP (pixels_p)
- ? FRAME_LINE_HEIGHT (f) * extract_float (vscroll)
- : extract_float (vscroll));
+ ? FRAME_LINE_HEIGHT (f) * XFLOATINT (vscroll)
+ : XFLOATINT (vscroll));
w->vscroll = min (w->vscroll, 0);
if (w->vscroll != old_dy)
height = safe_call1 (it->font_height,
face->lface[LFACE_HEIGHT_INDEX]);
if (NUMBERP (height))
- new_height = extract_float (height);
+ new_height = XFLOATINT (height);
}
else if (NUMBERP (it->font_height))
{
f = FACE_FROM_ID (it->f,
lookup_basic_face (it->f, DEFAULT_FACE_ID));
- new_height = (extract_float (it->font_height)
+ new_height = (XFLOATINT (it->font_height)
* XINT (f->lface[LFACE_HEIGHT_INDEX]));
}
else
unbind_to (count, Qnil);
if (NUMBERP (value))
- new_height = extract_float (value);
+ new_height = XFLOATINT (value);
}
if (new_height > 0)
return 0;
value = XCAR (XCDR (spec));
- if (NUMBERP (value) && extract_float (value) > 0)
+ if (NUMBERP (value) && XFLOATINT (value) > 0)
it->space_width = value;
}
if (NUMBERP (value))
{
struct face *face = FACE_FROM_ID (it->f, it->face_id);
- it->voffset = - (extract_float (value)
+ it->voffset = - (XFLOATINT (value)
* (normal_char_height (face->font, -1)));
}
#endif /* HAVE_WINDOW_SYSTEM */
/* Compute the max. number of lines specified by the user. */
if (FLOATP (Vmax_mini_window_height))
- max_height = extract_float (Vmax_mini_window_height) * total_height;
+ max_height = XFLOAT_DATA (Vmax_mini_window_height) * total_height;
else if (INTEGERP (Vmax_mini_window_height))
max_height = XINT (Vmax_mini_window_height) * unit;
else
height = WINDOW_BOX_TEXT_HEIGHT (w);
if (NUMBERP (aggressive))
{
- double float_amount = extract_float (aggressive) * height;
+ double float_amount = XFLOATINT (aggressive) * height;
int aggressive_scroll = float_amount;
if (aggressive_scroll == 0 && float_amount > 0)
aggressive_scroll = 1;
height = WINDOW_BOX_TEXT_HEIGHT (w);
if (NUMBERP (aggressive))
{
- double float_amount = extract_float (aggressive) * height;
+ double float_amount = XFLOATINT (aggressive) * height;
int aggressive_scroll = float_amount;
if (aggressive_scroll == 0 && float_amount > 0)
aggressive_scroll = 1;
scroll-*-aggressively. */
if (!scroll_conservatively && NUMBERP (aggressive))
{
- double float_amount = extract_float (aggressive);
+ double float_amount = XFLOATINT (aggressive);
pt_offset = float_amount * WINDOW_BOX_TEXT_HEIGHT (w);
if (pt_offset == 0 && float_amount > 0)
int base_unit = (width_p
? FRAME_COLUMN_WIDTH (it->f)
: FRAME_LINE_HEIGHT (it->f));
- return OK_PIXELS (extract_float (prop) * base_unit);
+ return OK_PIXELS (XFLOATINT (prop) * base_unit);
}
if (CONSP (prop))
if (NUMBERP (car))
{
double fact;
- pixels = extract_float (car);
+ pixels = XFLOATINT (car);
if (NILP (cdr))
return OK_PIXELS (pixels);
if (calc_pixel_width_or_height (&fact, it, cdr,
bool stretched_p
= it->char_to_display == ' ' && !NILP (it->space_width);
if (stretched_p)
- it->pixel_width *= extract_float (it->space_width);
+ it->pixel_width *= XFLOATINT (it->space_width);
/* If face has a box, add the box thickness to the character
height. If character has a box line to the left and/or
&& (lx0 = XCAR (XCAR (circ)), INTEGERP (lx0))
&& (ly0 = XCDR (XCAR (circ)), INTEGERP (ly0)))
{
- double r = extract_float (lr);
+ double r = XFLOATINT (lr);
double dx = XINT (lx0) - x;
double dy = XINT (ly0) - y;
return (dx * dx + dy * dy <= r * r);